package cn.stronglink.asset.module.basicdata.assetTypeAttr.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.stronglink.asset.model.AssetTypeAttr;
import cn.stronglink.asset.module.basicdata.assetTypeAttr.service.AssetTypeAttrService;
import cn.stronglink.suite.core.base.AbstractController;
import cn.stronglink.suite.core.log.annotation.OperateLog;
import cn.stronglink.suite.core.log.annotation.OperateLog.OpType;

@Controller
@RequestMapping(value = "basic/assetTypeAttr")
public class AssetTypeAttrController extends AbstractController {

	@Autowired
	private AssetTypeAttrService assetTypeAttrService;
	
	@RequestMapping(value = "queryList")
	public ResponseEntity<ModelMap> queryList(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response, @RequestBody Map<String, Object> params) {
		List<AssetTypeAttr> data = assetTypeAttrService.queryAssetTypeAttr(params);
		return setSuccessModelMap(modelMap, data);
	}
	
	/**
	 * 查询属性对象
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "qryById")
	public ResponseEntity<ModelMap> qryById(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response, @RequestBody Long id) {		
		AssetTypeAttr data = assetTypeAttrService.qryById(id);
		return setSuccessModelMap(modelMap, data);
	}
	/**
	 * 新增资产属性
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param assetTypeAttr
	 * @return
	 */
	@OperateLog(module = "资产动态属性管理",desc="添加资产动态属性", type = OpType.ADD)
	@RequestMapping(value = "create")
	public ResponseEntity<ModelMap> create(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody AssetTypeAttr assetTypeAttr) {
		assetTypeAttrService.insertAssetTypeAttr(assetTypeAttr);
		return setSuccessModelMap(modelMap, null);
	}
	/**
	 * 编辑资产属性
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param assetTypeAttr
	 * @return
	 */
	@OperateLog(module = "资产动态属性管理",desc="编辑资产动态属性", type = OpType.UPDATE)
	@RequestMapping(value = "edit")
	public ResponseEntity<ModelMap> edit(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody AssetTypeAttr assetTypeAttr) {
		assetTypeAttrService.insertAssetTypeAttr(assetTypeAttr);
		return setSuccessModelMap(modelMap, null);
	}
	
	/**
	 * 删除属性
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@OperateLog(module = "资产动态属性管理",desc="删除资产动态属性", type = OpType.DEL)
	@RequestMapping(value = "remove")
	public ResponseEntity<ModelMap> remove(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody Long id) {
		assetTypeAttrService.removeAssetTypeAttr(id);
		return setSuccessModelMap(modelMap, null);
	}

}
